package com.lichongbing.lyoggl.service.impl;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lichongbing.lyoggl.mapper.AccountMapper;
import com.lichongbing.lyoggl.model.Money;
import com.lichongbing.lyoggl.model.ReportMounth;
import com.lichongbing.lyoggl.service.MoneyService;
import com.lichongbing.lyoggl.mapper.MoneyMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 *
 * @author lichongbing
 */
@Service
public class MoneyServiceImpl extends ServiceImpl<MoneyMapper, Money>
    implements MoneyService{
    @Autowired
    private MoneyMapper moneyMapper;
    @Override
    public List<Money> findByUid(String userid) {
        return moneyMapper.findByUid(userid);
    }

    @Override
    public int deleteByUid(String id, String userid) {
        return moneyMapper.deleteByUid(id,userid);
    }

    @Override
    public ReportMounth reportMounth(String mouth,String year, String userid) {
        ReportMounth reportMounth = new ReportMounth();
        String money0 =  moneyMapper.getMoney0(mouth,year,userid);
        String money1 =  moneyMapper.getMoney1(mouth,year,userid);
        String pay1 =  moneyMapper.getPay1(mouth,year,userid);
        String pay2 =  moneyMapper.getPay2(mouth,year,userid);
        String duting =  moneyMapper.getDuting(userid);
        String duted =  moneyMapper.getDuted(userid);
        String balance = moneyMapper.getBalance(userid);
        reportMounth.setMoney0(money0);
        reportMounth.setMoney1(money1);
        reportMounth.setPay1(pay1);
        reportMounth.setPay2(pay2);
        reportMounth.setDuting(duting);
        reportMounth.setDuted(duted);
        reportMounth.setBalance(balance);
        return reportMounth;
    }

    @Override
    public String reportDay(String day, String year, String mouth,String userid) {
        return moneyMapper.reportDay(day, year, mouth,userid);
    }


}
